{include file=header.html}
<link type="text/css" rel="stylesheet" href="{res file=css/tuan.css}"/>
<script type="text/javascript" src="{res file=js/touchslider.dev.js}"></script>
<script type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}" charset="utf-8"></script>
<!---------详情页------------->
<div class="detail_img tuan_con">
    <!-- {if $goods._images } -->
    <div  class="sliders" >
        <ul class="sliderlist" id="slider">
            <!--{foreach from=$goods._images item=goods_image name=fe_goods_image}-->
            <li><img src="{$site_url}/{$goods_image.thumbnail}"></li>
            <!--{/foreach}-->
        </ul>
    </div>
    <script type="text/javascript">
        var t1 = new TouchSlider('slider', {speed: 600, timeout: 3000, direction: 'left', align: 'left'})
    </script>
    <!-- {else} -->
    <div class="imgbox">
        <img src="{$site_url}/{$goods.default_image}">
    </div>
    <!-- {/if} -->
    <form method="post" id="join_group_form" action="index.php?app=groupbuy&amp;id={$group.group_id}">
        <h2 class="tuan_tit">
            <p class="info">{$group.group_name|escape}</p>
            <p class="time"><strong>{$group.state_desc}</strong>
        </h2>
        <div class="tuan_info">
            <ul>
                <li>
                    <p class="title">{$lang.start_end_time}：</p>
                    <p class="con"><b>{$group.start_time|date:Y-m-d} </b>{$lang.zhi}<b>{$group.end_time|date:Y-m-d}</b></p>
                </li>
                <li>
                    <p class="title">{$lang.quantity_sold}：</p>
                    <p class="con">
                        <span>
                            <b>
                                {$group.min_quantity}
                                {if $group.min_quantity gt $group.quantity}
                                ({$lang.short_of}{$group.left_quantity})
                                {else}
                                ({$lang.joined}{$group.quantity})
                                {/if}
                            </b>
                        </span>
                    </p>
                </li>

                <!-- {if $group.max_per_user gt 0} -->
                <li>
                    <p class="title">{$lang.max_per_user}：</p>
                    <p class="con"><b> {$group.max_per_user}</b></p>
                </li>
                <!-- {/if} -->

                <li>
                    <p class="title">{$lang.group_desc}：</p>
                    <p class="con">  <!-- {if $group.group_desc} -->
                        {$group.group_desc}
                        <!-- {else} -->
                        {$lang.no_desc}
                        <!-- {/if} -->
                    </p>
                </li>
            </ul>
        </div>
        <div class="tuan_name">
            {$lang.goods_name}：{$goods.goods_name}
        </div>
        <div class="info_table">
            <table>
                <tbody>
                    <tr>
                        <th>{$goods.spec_name|escape}</th>
                        <th>{$lang.original_price}</th>
                        <th>{$lang.group_price}</th>
                        <!-- {if $group.ican.join or $group.ican.join_info} -->
                        <th>{$lang.buy_quantity}</th>
                        <!-- {/if} -->

                    </tr>
                    <!-- {foreach from=$goods._specs item=spec} -->
                    <tr>
                        <td>
                            {$spec.spec}<input ectype="spec" name="spec[]" type="hidden" class="text" value="{$spec.spec}" /><input ectype="spec_id" name="spec_id[]" type="hidden" class="text" value="{$spec.spec_id}" />
                        </td>
                        <td style="text-decoration:line-through">{$spec.price|price}</td>
                        <td style="color:#b20005">{$spec.group_price|price}</td>
                        <!-- {if $group.ican.join or $group.ican.join_info} -->
                        <td>
                            <!-- {if $group.ican.join} --><input ectype='quantity' name="quantity[]" type="text" class="nums" /><!-- {/if} -->
                            <!-- {if $group.ican.join_info} -->{$spec.my_qty}<!-- {/if} -->
                        </td>
                        <!-- {/if} -->

                    </tr>
                    <!-- {/foreach} -->
                </tbody>
            </table>
        </div>

        <div class="tuan_btn">
            <!-- {if $group.ican.join_info} -->

            <!-- {/if} -->
            <!-- {if $group.ican.exit} -->
            <input name="exit" class="red_btn" type="submit" value="{$lang.joined_this_groupbuy},{$lang.click}{$lang.exit_groupbuy}" />
            <!-- {/if} -->
            <!-- {if $group.ican.buy} -->
            <input name="buy" class="red_btn" onclick="window.location.href = 'index.php?app=order&goods=groupbuy&group_id={$smarty.get.id}'" type="button" value="{$lang.buy}" />
            <!-- {/if} -->
        </div>

        <!-- {if $group.ican.join} -->
        <div class="tuan_btn">
            <input type="button" value="{$lang.join_groupbuy}" class="red_btn" id="join">
        </div>
        <div id="info"  class="tuan_user" style="display: none;">
            <h2>{$lang.join_user_info}<a href="javascript:;" id='close' class="close"><img src="{res file=images/close.png}"></a></h2>
            <p class="tit">{$lang.join_tips}</p>
            <p>{$lang.real_name}：<input type="text" name="link_man" class="tu_txt"></p>
            <p>{$lang.tel}：<input type="text" name="tel" class="tu_txt"></p>
            <div class="tuan_btn">
                <input type="submit" value="{$lang.join_groupbuy}" name="join" class="red_btn" >
            </div>
        </div>
        <!-- {/if}  -->
</div>
</form>

<div class="detail_con">
    <ul class="tab">
        <li class="cur">{$lang.commodity_details}</li>
        <li>{$lang.group_log}</li>
    </ul>
    <div class="tab_con">
        <ul class="zx_list">
            {$goods.description}
        </ul>
    </div>
    <div class="tab_con" style="display:none;">
        <ul class="comments_list">
            <!-- {foreach from=$join_list item=user} -->
            <li>{$user.user_name}</li>
            <!-- {foreachelse} -->
            <li>{$lang.no_groupbuy_log}</li>
            <!-- {/foreach} -->
        </ul>
    </div>
</div>
<!----------tab切换--------------->
<script type="text/javascript">
        jQuery(function(jq) {
            function changeTab(lis, divs) {
                lis.each(function(i) {
                    var els = jq(this);
                    els.click(function() {
                        lis.removeClass();
                        divs.stop().hide().animate({'opacity': 0}, 0);
                        jq(this).addClass("cur");
                        divs.eq(i).show().animate({'opacity': 1}, 300);
                    });
                });
            }
            var rrE = jq(".detail_con");
            changeTab(rrE.find(".tab li"), rrE.find(".tab_con"));

        });
</script>
<!------底部-------->




<script type="text/javascript">
//<!CDATA[
    $(function() {
        $('#join').click(function() {
            var qty = 0;
            var error = false;
            var max_per_user = {$group.max_per_user};
            $('input[ectype="quantity"]').each(function() {
                if (parseInt($(this).val()) > 0) {
                    qty += parseInt($(this).val());
                }
                if ($(this).val() != '' && (parseInt($(this).val()) < 0 || isNaN(parseInt($(this).val()))))
                {
                    error = true;
                }
            });
            if ('{$group.ican.login}') {
                alert('{$lang.need_login}');
                var SITE_URL = "{$site_url}/mobile";
                window.location.href = SITE_URL + '/index.php?app=member&act=login&ret_url=' + encodeURIComponent('index.php?app=groupbuy&id={$group.group_id}');

            } else if (error == true) {
                alert('{$lang.invalid_quantity}');
            } else if (qty == 0) {
                alert('{$lang.fill_quantity}');
            } else if (max_per_user > 0 && qty > max_per_user) {
                alert('{sprintf lang=error_max_per_user var1=group.max_per_user}');
            } else {
                $('#info').show();
                $('input[name="link_man"]').focus();
                $('input[ectype="quantity"]').attr('disabled', true);
            }
        });
        $('#close').click(function() {
            $('#info').hide();
            $('input[ectype="quantity"]').attr('disabled', false);
        });
        $('#join_group_form').submit(function() {
            $('input[ectype="quantity"]').attr('disabled', false);
        });

        $('input[name="exit"]').click(function() {
            if (!confirm('{$lang.confirm_exit}')) {
                return false;
            }
        });

        $('#join_group_form').validate({
            errorPlacement: function(error, element) {
                $(element).next('.field_notice').hide();
                $(element).after(error);
            },
            onkeyup: false,
            rules: {
                link_man: {
                    required: true
                },
                tel: {
                    checkTel: true
                }
            },
            messages: {
                link_man: {
                    required: '{$lang.fill_join_user_info}'
                },
                tel: {
                    checkTel: '{$lang.fill_join_user_info}'
                }
            }
        });
    });

//]]>
</script>
{include file=footer.html}